package com.onpositive.inferencer;

import com.onpositive.data.IPropertyMetadata;
import com.onpositive.data.IReadableObjectCollection;
import com.onpositive.inferencer.test.LinkSplitter;
import com.onpositive.semantic.model.api.property.ComputedProperty;

public class SerializedCollectionProp extends ComputedProperty{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@SuppressWarnings("rawtypes")
	protected IReadableObjectCollection collection;
	protected IPropertyMetadata meta;

	@SuppressWarnings("rawtypes")
	public SerializedCollectionProp(IReadableObjectCollection collection2,
			IPropertyMetadata meta2) {
		super(meta2.id(),meta2.id());
		this.meta=meta2;
		this.collection=collection2;
	}

	@SuppressWarnings("unchecked")
	@Override
	public Object getValue(Object obj) {
		Object value = collection.getValue(obj, meta);
		if (value instanceof String){
			return LinkSplitter.getLinks(value.toString());
		}
		return value;
	}
	
}
